#include <iostream>
#include <list>
using namespace std;

int main()
{
	int N; cin >> N;
	while (N--) {
		int n; cin >> n;
		list<int> l;
		for (int i = 1; i <= n; i++) l.push_back(i);
		while (l.size() > 3) {
			int c = 1;
			for (auto it = l.begin(); it != l.end(); ) {
				if (c++ == 2) it = l.erase(it);
				else it++, c = 2;
			}
			if (l.size() > 3) {
				c = 1;
				for (auto it = l.begin(); it != l.end(); ) {
					if (c++ == 3) it = l.erase(it);
					else {
						if (c > 3) c = 2;
						it++;
					}
				}
			}
		}
		auto it = l.begin();
		cout << *(it++);
		while (it != l.end())
			cout << ',' << * (it++);
		if(N) cout << endl;
	}
	
	return 0;
}
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// 1 3 5 7 9 11 13 15 17 19
// 1 3 7 9 13 15 19
// 1 7 13 19
// 1 7 19